package com.igoal.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.compass.annotations.SearchableProperty;

@Entity
@Table(name = "wall_update")
public class WallUpdate implements Serializable, Audit {

	private static final long serialVersionUID = 1132458702940626015L;

	private Long id;
	private PrivacySetting privacy;
	// private User actionOwner;
	private User componentOwner;
	private ComponentEnum component;
	private ActionTypeEnum action;
	private long componentId;
	private Date createDate;
	private Date updateDate;
	private DataStatus status;	

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "privacy", nullable = false)
	public PrivacySetting getPrivacy() {
		return this.privacy;
	}

	public void setPrivacy(PrivacySetting privacy) {
		this.privacy = privacy;
	}

	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "action_owner", nullable = false)
	// public User getActionOwner() {
	// return this.actionOwner;
	// }
	//
	// public void setActionOwner(User userByActionOwner) {
	// this.actionOwner = userByActionOwner;
	// }

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "component_owner", nullable = false)
	public User getComponentOwner() {
		return this.componentOwner;
	}

	public void setComponentOwner(User userByComponentOwner) {
		this.componentOwner = userByComponentOwner;
	}

	@Enumerated(EnumType.STRING)
	@Column(name = "component", nullable = false)
	public ComponentEnum getComponent() {
		return this.component;
	}

	public void setComponent(ComponentEnum component) {
		this.component = component;
	}

	@Column(name = "component_id", nullable = false)
	public long getComponentId() {
		return this.componentId;
	}

	public void setComponentId(long componentId) {
		this.componentId = componentId;
	}

	@Enumerated(EnumType.STRING)
	@Column(name = "action", nullable = false)
	public ActionTypeEnum getAction() {
		return this.action;
	}

	public void setAction(ActionTypeEnum action) {
		this.action = action;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "mdate", nullable = false, length = 19)
	public Date getUpdateDate() {
		return this.updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "cdate", nullable = false, length = 19)
	public Date getCreateDate() {
		return this.createDate;
	}
	
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Enumerated(EnumType.STRING)
	@Column(nullable=false, name="status")
	@SearchableProperty
	public DataStatus getStatus() {
		return status;
	}

	public void setStatus(DataStatus dataStatus) {
		this.status = dataStatus;
	}
	
}
